import { createRouter, createWebHistory } from "vue-router";

export const Layout = () => import("@/layout/index.vue");

// 公共路由
export const constantRoutes = [
  {
    path: "/chat",
    component: () => import("@/views/chat")
  },
  {
    path: "/login",
    component: () => import("@/views/login.vue"),
    hidden: true
  },
  {
    path: "/register",
    component: () => import("@/views/register.vue"),
    hidden: true
  },
  {
    path: "",
    component: () => import("@/views/index.vue"),
    name: "Index"
  }
];

const router = createRouter({
  history: createWebHistory(import.meta.env.VITE_APP_CONTEXT_PATH),
  strict: true,
  routes: constantRoutes,
  scrollBehavior: () => ({ left: 0, top: 0 })
});

export const setupRouter = (app) => {
  app.use(router);
};

export default router;
